package com.junjie.checkin.entity.Enum;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.junjie.checkin.entity.Enum.StringValuedEnum;
import lombok.Getter;

import java.util.Arrays;

/**
 * @author 洪浚杰
 * @description
 * @date 2025/6/19 11:19
 */
@Getter
public enum PointRecordTypeEnum implements StringValuedEnum {

    ACTIVITY("activity",0),
    GIFT("gift",1),
    MANUAL("manual",2);
    private final String value;
    private final Integer index;
    @JsonCreator
    public static PointRecordTypeEnum fromValue(String value) {
        return Arrays.stream(values())
                .filter(e -> e.getValue().equalsIgnoreCase(value))
                .findFirst()
                .orElseThrow(() -> new IllegalArgumentException("Invalid value: " + value));
    }
    private PointRecordTypeEnum(String value, Integer index) {
        this.value = value;
        this.index = index;
    }
}
